package com.ms.oschina.viewholder;

import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.ms.oschina.R;
import com.ms.oschina.base.BaseViewHolder;
import com.ms.oschina.bean.Comment;
import com.ms.oschina.util.StringUtils;
import com.ms.oschina.util.UiUtils;
import com.ms.oschina.view.CircleImageView;
import com.ms.oschina.view.TextViewFixTouchConsume;
import com.squareup.picasso.Picasso;

public class TweetCommentViewHolder extends BaseViewHolder<Comment> {

	private CircleImageView civTweetcommentUserAvatar;
	private TextView tvTweetcommentUserName;
	private TextView tvTweetcommentCommentTime;
	private TextViewFixTouchConsume tvTweetcommentCommentContent;

	private void findViews(View view) {
		civTweetcommentUserAvatar = (CircleImageView) view
				.findViewById(R.id.civ_aboutme_userAvatar);
		tvTweetcommentUserName = (TextView) view
				.findViewById(R.id.tv_tweetcomment_userName);
		tvTweetcommentCommentTime = (TextView) view
				.findViewById(R.id.iv_event_time);
		tvTweetcommentCommentContent = (TextViewFixTouchConsume) view
				.findViewById(R.id.tv_aboutme_commentContent);
	}

	@Override
	public View initView() {
		View view = UiUtils.inflate(R.layout.tem_tweetcomment);
		findViews(view);
		return view;
	}

	@Override
	public void setData(int position, Comment data) {

		String portrait = data.getPortrait();
		if (!TextUtils.isEmpty(portrait)) {
			Picasso.with(UiUtils.getContext()).load(portrait)
					.placeholder(R.drawable.widget_dface)
					.into(civTweetcommentUserAvatar);
		}
		tvTweetcommentUserName.setText(data.getAuthor());
		tvTweetcommentCommentContent.setText(data.getContent());
		tvTweetcommentCommentTime.setText(StringUtils.friendly_time(data
				.getPubDate()));
	}

}
